﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MediaRecommender.Model;

namespace MediaRecommender.Model
{
    public class Events
    {
        #region Dataindkapsling
        public class MediaArgs : EventArgs
        { 
            public MediaArgs(Media MediaIn)
            {
                this.MediaList = MediaIn;
            }

            public readonly Media MediaList;
        }

        public class UserArgs : EventArgs
        {
            public UserArgs(User UserIn)
            {
                this.User = UserIn;
            }
            public readonly User User;
        }
        #endregion

        #region Properties

        private Media _mediaAdd;
        public Media MediaList
        {
            get { return _mediaAdd; }
            set
            {
                _mediaAdd = value;
                MediaListChanged(new MediaArgs(value));
            }
        }

        private User _userToChange;
        public User UserToChange
        {
            get { return _userToChange; }
            set
            {
                _userToChange = value;
                UserChanged(new UserArgs(value));

            }
        }

        #endregion

        #region Event

        public event EventHandler<MediaArgs> MediaListChange = delegate { };

        protected virtual void MediaListChanged(MediaArgs e)
        {
            if (MediaListChange != null)
                MediaListChange(this, e);
        }

        public event EventHandler<UserArgs> UserChange = delegate { };

        protected virtual void UserChanged(UserArgs e)
        {
            if (UserChange != null)
                UserChange(this, e);
        }


        #endregion
    }
}